import paste.deploy
import runnd.models as model
from pylons.database import create_engine

def setup_config(command, filename, section, vars):
    """
    Place any commands to setup runnd here.
    """
    conf = paste.deploy.appconfig('config:' + filename)
    conf.update(dict(app_conf=conf.local_conf, global_conf=conf.global_conf))
    paste.deploy.CONFIG.push_process_config(conf)

    # Setup the database
    uri = conf['sqlalchemy.dburi']
    engine = create_engine(uri)
    print "Creating tables"
    model.metadata.create_all(connectable=engine)
    print "Successfully setup"

